*** Settings ***
Resource   ../Common_Head.robot


*** Variables ***


*** Keywords ***
Modify Excel File
    [Documentation]    Modify the download file(.xlsx)
    [Arguments]    ${file_path}    ${Row}    ${Col}    ${Sheet_name}    ${Value}
    Wait Until Keyword Succeeds    50    1    Open Excel Document    ${file_path}    ${Sheet_name}
    Write Excel Cell    ${Row}    ${Col}    ${Value}    ${Sheet_name}
    Save Excel Document    ${file_path}
    Close All Excel Documents
    [Return]    ${file_path}

Check A Dialog displays After Clicking Lane_Magm button
    [Arguments]    ${Title}
    Click    ${Project_toolbar_LaneManagementButton}
    Wait Until Keyword Succeeds    10x    400ms    Get Page Source    contains    ${Title}    120
    Wait For Elements State    ${Project_LaneMgmt_UpdateInfo}    visible    30
    Wait For Elements State    ${Project_LaneMgmt_DeleteInfo}    visible
    Wait For Elements State    ${Project_LaneMgmt_AddInfo}    visible
    Wait For Elements State    ${Project_LaneMgmt_NextButton}    visible
    Wait For Elements State    ${Project_LaneMgmt_CloseButton}    visible


User select location/Port routing
    [Arguments]    ${PROJECT.MODE}=AIR    ${Select_By}=Location
    IF    '${Select_By}' == 'Location'
        ${Status}    Run Keyword And Return Status    Get Checkbox State    xpath=//input[@value='location']    ==    checked
        IF    '${Status}' == 'False'
            Click    xpath=//input[@value='location']
        END
    ELSE
        ${Status}    Run Keyword And Return Status    Get Checkbox State    xpath=//input[@value='port']    ==    checked
        IF    '${Status}' == 'False'
            Click    xpath=//input[@value='port']
        END
    END

    Log    ${PROJECT.MODE}
    IF    '${PROJECT.MODE}' == 'AIR'
        Check Mapping Columns Checkbox In Lane Mangement    ${PROJECT.MODE}
        Select Location Routing In Lane Management    ${PROJECT.MODE}
    ELSE
        Check Mapping Columns Checkbox In Lane Mangement    ${PROJECT.MODE}
        Select Location Routing In Lane Management    ${PROJECT.MODE}
    END
Select Location Routing In Lane Management
    [Documentation]    Just include AIR and FCL mode
    [Arguments]    ${PROJECT.MODE}=AIR
    IF    '${PROJECT.MODE}' == 'AIR'
        Wait For Elements State   ${FCL/AIR_Select_OriginCountry}     enabled
        Select Options By   ${FCL/AIR_Select_OriginCountry}    label    Country from - F
        Select Options By   ${FCL/AIR_Select_DestinationCountry}    label    Country to - I
        Select Options By   ${AIR_Select_DBServiceLevel}    label    Schenker Service Level - C
        Select Options By   ${AIR_Select_CustomerServiceLevel}    label    TSP - Transport Service Provider - B
        Select Options By   ${AIR_Select_MD/LD}     label    MD/LD - K
        Select Options By   ${FCL/AIR_Select_CustomerLaneID}    label    Lane ID code - D
        Select Options By   ${FCL/AIR_Select_OriginType}    label    Origin Type - P
        Select Options By   ${FCL/AIR_Select_DestType}    label    Des Type - Q
        Select Options By   ${FCL/AIR_Select_OriginPostalCode}    label    Origin Postal Code - R
        Select Options By   ${FCL/AIR_Select_DestiPostalCode}    label    Destination Postal Code - S
        Select Options By   ${AIR_Select_CustomerOrginPort}    label    Customer Origin Airport - T
        Select Options By   ${AIR_Select_CustomerDestionaPort}    label    Customer Destination Airport - U
        Select Options By   ${AIR_Select_NoOfShipments}    label    Number of Shippments - V
        Select Options By   ${AIR_Select_VolumeCBM}    label    Volume(cbm) - W
        Select Options By   ${AIR_Select_ActWghtInKg}    label    Actual weight in kg - X
        Select Options By   ${AIR_Select_ChrgWghtInKg}    label    Chargeable weight in kg - Y
        Select Options By   ${FCL/AIR_Select_CommDesc}    label    Commodity Description - Z
        Select Options By   ${AIR_Select_CommdRemarks}    label    Commodity Remarks - AA
        Select Options By   ${AIR_Select_DGRClass}    label    DGR Class - AB
        Select Options By   ${AIR_Select_DGRUNNo}   label    DGR UN No. - AC
        Select Options By   ${AIR_Select_DGRPAX/CAO}    label    DGR PAX/CAO. - AD
        Select Options By   ${AIR_Select_DTA}    label    Transit Time Door to Airport in hours - L
        Select Options By   ${AIR_Select_ATA}    label    Transit Time Airport to Airport in hours - M
        Select Options By   ${AIR_Select_ATD}    label    Transit Time Airport to Door in hours - N
        Select Options By   ${AIR_Select_DTD}    label    Transit Time Door to Door in hours - O
    ELSE
        Wait For Elements State   ${FCL/AIR_Select_OriginCountry}     enabled    30
        Select Options By   ${FCL/AIR_Select_OriginCountry}      label    ${SPACE}${SPACE}country from - D
        Select Options By   ${FCL/AIR_Select_DestinationCountry}      label    ${SPACE}${SPACE}country to - G
        Select Options By   ${FCL_Select_Origin_State}    label    State From - E
        Select Options By   ${FCL_Select_Destination_State}    label    State To - H
        Select Options By   ${FCL/AIR_Select_OriginType}    label    origin type - I
        Select Options By   ${FCL/AIR_Select_DestType}    label    des type - J
        Select Options By   ${FCL/AIR_Select_OriginPostalCode}    label    Origin Postal Code - K
        Select Options By   ${FCL/AIR_Select_DestiPostalCode}    label    Destination Postal Code - L
        Select Options By   ${FCL_Select_CustomerDelTerm}    label    Customer's\nDelivery\nTerm - M
        Select Options By   ${FCL/AIR_Select_CustomerLaneID}    label    Lane ID code - B
        Select Options By   ${FCL_Select_VolumeCont20}    label    Volume\nContainers\n20 - P
        Select Options By   ${FCL_Select_VolumeCont40}    label    Volume\nContainers\n40 - Q
        Select Options By   ${FCL_Select_VolumeCont40HC}    label    Volume\nContainers\n40HC - R
        Select Options By   ${FCL_Select_VolumeCont45}    label    Volume Containers 45 - S
        Select Options By   ${FCL_Select_VolumeTEUTotal}    label    Volume\nTEU\nTota - T
        Select Options By   ${FCL/AIR_Select_CommDesc}    label    Commodity\nDescription - U
        Select Options By   ${FCL_Select_IMOClass}    label    IMO Class - V
        Select Options By   ${FCL_Select_IMOUNNo}    label    IMO UN No. - W
    END

Check Mapping Columns Checkbox In Lane Mangement
    [Documentation]    Just include FCL and Air Mode
    [Arguments]    ${PROJECT.MODE}=FCL
    Wait For Elements State    ${FCL/AIR_CheckBox_OriginType}    enabled    30
    Check Checkbox    ${FCL/AIR_CheckBox_OriginType}
    Check Checkbox    ${FCL/AIR_CheckBox_DestType}
    Check Checkbox    ${FCL/AIR_CheckBox_OriginPostalCode}
    Check Checkbox    ${FCL/AIR_CheckBox_DestiPostalCode}
    Check Checkbox    ${FCL/AIR_CheckBox_CustomerLaneID}
    IF    '${PROJECT.MODE}' == 'FCL'
        Check Checkbox    ${FCL_CheckBox_CustomerDelTerm}
        Check Checkbox    ${FCL_CheckBox_CustomerPortofDischarge}
        Check Checkbox    ${FCL_CheckBox_VolumeCont20}
        Check Checkbox    ${FCL_CheckBox_VolumeCont40}
        Check Checkbox    ${FCL_CheckBox_VolumeCont40HC}
        Check Checkbox    ${FCL_CheckBox_VolumeCont45}
        Check Checkbox    ${FCL_CheckBox_VolumeTEUTotal}
        Check Checkbox    ${FCL/AIR_CheckBox_CommDesc}
        Check Checkbox    ${FCL_CheckBox_IMOClass}
        Check Checkbox    ${FCL_CheckBox_IMOUNNo}
        Check Checkbox    ${FCL_CheckBox_CustomerDelTerm}
        Check Checkbox    ${FCL_CheckBox_CustomerPortofDischarge}
    ELSE
        Check Checkbox    ${AIR_CheckBox_NoOfShipments}
        Check Checkbox    ${AIR_CheckBox_VolumeCBM}
        Check Checkbox    ${AIR_CheckBox_ActWghtInKg}
        Check Checkbox    ${AIR_CheckBox_ChrgWghtInKg}
        Check Checkbox    ${AIR_CheckBox_DGRClass}
        Check Checkbox    ${AIR_CheckBox_DGRUNNo}
        Check Checkbox    ${AIR_CheckBox_DGRPAX/CAO}
        Check Checkbox    ${AIR_CheckBox_DTA}
        Check Checkbox    ${AIR_CheckBox_ATA}
        Check Checkbox    ${AIR_CheckBox_ATD}
        Check Checkbox    ${AIR_CheckBox_DTD}
        Check Checkbox    ${AIR_CheckBox_CommdRemarks}
        Check Checkbox    ${AIR_CheckBox_CustomerServiceLevel}
        Check Checkbox    ${AIR_CheckBox_MD/LD}
        Check Checkbox    ${AIR_CheckBox_DBServiceLevel}
        Check Checkbox    ${AIR_CheckBox_CustomerOrginPort}
        Check Checkbox    ${AIR_CheckBox_CustomerDestionaPort}
    END